package com.healthcare.client.controller;


import com.healthcare.client.form.ApplyGroupForm;
import com.healthcare.client.form.ApplyReferralForm;
import com.healthcare.client.pojo.Patient;
import com.healthcare.client.service.PatientService;
import com.healthcare.client.vo.PatientEditVo;
import com.healthcare.common.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 患者表 前端控制器
 * </p>
 *
 * @author 新华医院转诊联盟
 * @since 2020-04-13
 */
@Api(tags = "前台患者信息管理")
@CrossOrigin
@RestController
@RequestMapping("/client/patient")
public class PatientController {

    @Autowired
    private PatientService patientService;

    @ApiOperation("加载患者详细信息")
    @GetMapping("getPatientEditVo/{examineId}/{patientId}/{type}")
    public Result getPatientEditVo(
                                   @ApiParam(name = "examineId",value = "会诊或转诊id",required = true)
                                   @PathVariable Integer examineId,
                                   @ApiParam(name = "patientId",value = "患者id",required = true)
                                   @PathVariable Integer patientId,
                                   @ApiParam(name = "type",value = "类型，用来区分是会诊还是转诊 0- 会诊 1 转诊 ",required = true)
                                   @PathVariable Integer type){
           PatientEditVo patientEditVo =  patientService.getPatientEditVo(examineId,patientId,type);
           return Result.ok().data("datas",patientEditVo);
    }

    @ApiOperation("更新患者详细信息")
    @PutMapping("updatePatientInfo/{type}")
    public Result updatePatientInfo(
            @ApiParam(name = "type",value = "类型，用来区分是会诊还是转诊 0- 会诊 1 转诊 ",required = true)
            @PathVariable Integer type,
            @ApiParam(name = "applyReferralForm",value = "表单对象",required = true)
            @RequestBody ApplyReferralForm applyReferralForm){
        patientService.updatePatientInfo(type,applyReferralForm);
        return Result.ok();
    }

}

